﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05BiggerThanNeighbor
{
    class Program
    {
        static bool BiggerThanNeighbor(int[] array, int i)
        {
            bool isBigger = false;
            if ((i > 0) && (i < array.Length - 1))
            {
                if ((array[i] > array[i-1]) && (array[i] > array[i+1]))
                {
                    isBigger = true;
                }
            }
            if (i == 0)
            {
                if (array[i] > array[i+1])
                {
                    isBigger = true;
                }
            }
            if (i == (array.Length - 1))
            {
                if (array[i] > array[i - 1])
                {
                    isBigger = true;
                }
            }
            return isBigger;
        }
        static void Main(string[] args)
        {
            Console.Write("Array size:");
            int arraySize = int.Parse(Console.ReadLine());
            int[] array = new int[arraySize];
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write("array[{0}]:", i);
                array[i] = int.Parse(Console.ReadLine());
            }
            Console.Write("Which element to compare:");
            int element = int.Parse(Console.ReadLine());
            Console.WriteLine("Is the element bigger than its neighbors? {0}", BiggerThanNeighbor(array, element));
        }
    }
}
